package com.huyn.baseframework.model;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * Created by huyaonan on 16/5/16.
 */
public class Category implements Serializable {
    public String launchclass;
//    public String moduleId;
    public String modelCode;
    public String modelDesc;
    public String modelName;

    //为了同一模块的复用起的别名
    public String subModelCode;

    //附加字段,非api
    public String templateType;
    public String relatedId;

    public CategorySimple getSimpleCategory() {
        CategorySimple mCate = new CategorySimple();
        mCate.launchclass = launchclass;
        mCate.modelCode = modelCode;
        mCate.modelDesc = modelDesc;
        mCate.modelName = modelName;
        mCate.templateType = templateType;
        mCate.relatedId = relatedId;
        mCate.subModelCode = subModelCode;
        mCate.modelExtra = modelExtra;
        return mCate;
    }
    
    public List<Object> dataDetail;

    //所有冗余字段都在这里
    public Object modelExtra;

    public int size() {
        return dataDetail==null?0:dataDetail.size();
    }

    public String getModelCode() {
        return modelCode + "_" + subModelCode;
    }

    public Object getStrFromExtra(String key) {
        try {
            if(modelExtra == null)
                return null;
            LinkedHashMap<String, Object> lhm = (LinkedHashMap<String, Object>) modelExtra;
            return lhm.get(key);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

}
